package net.xumf.support.enums;

import lombok.Getter;
import net.xumf.support.exception.NotFoundEnumInfoException;

import java.util.Arrays;

@Getter
public enum ReportJiraCondition {

    MORE_THAN(1, ">"),
    LESS_THAN(2, "<"),
    EQUAL(3, "="),
    GREATER_THAN_OR_EQUAL_TO(4, ">="),
    LESS_THAN_OR_EQUAL_TO(5, "<="),
    NOT_EQUAL_TO(6, "!="),
    IN(7, "in"),
    NOT_IN(8, "not in"),
    BETWEEN(9, "between"),
    LIKE(10, "like"),
    ;

    ReportJiraCondition(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    private int code;
    private String msg;

    public static ReportJiraCondition getByCode(int code) {
        return Arrays.stream(values()).filter(o -> o.code == code).findAny()
                .orElseThrow(() -> new NotFoundEnumInfoException(CodeEnum.ENUM_NOT_FOUND_ERROR));
    }
}
